package com.imay.live.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.imay.live.fragment.dynamics.DynamicsParams;

import java.util.List;


/**
 * Created by liangzhenxiong on 2017/04/14 0014.
 * 动态  图片、视频 等
 */

public class FeedModel implements MultiItemEntity, Parcelable {
    /**
     * feedId : 22835
     * uid : 24285
     * feedType : 1
     * imgUrl : https://imgs.imay.com/pic-24285-1490619289-7692.jpg
     * videoUrl :
     * msg : ❤
     * createTime : 1490619289
     * countLike : 30
     * countComment : 0
     * countRepost : 0
     * city : 石家庄市
     * longitude : 114431602
     * latitude : 38030357
     * atUsers : []
     * labels : [""]
     * repostedFeed : null
     * isLike : false
     * user : {"uid":24285,"roomId":136063,"nick":"牙牙乐~","imgHead":"https://imgs.imay.com/pic-24285-1482398013-4255.png","sex":2,"userLevel":19,"liveLevel":28,"vip":1,"city":"","myFollow":false,"isLive":0,"UserLv":19,"LiveLv":28,"LargeVipStatus":3,"LiveStatus":0}
     */

    private int feedId;
    private int uid;
    private int feedType;
    private String imgUrl;
    private String videoUrl;
    private String msg;
    private long createTime;
    private int countLike;
    private int countComment;
    private int countRepost;
    private String city;
    private int longitude;
    private int latitude;
    private FeedModel repostedFeed;
    private boolean isLike;
    private UserModel user;
    private List<UserModel> atUsers;
    private List<String> labels;
    private int familyId;
    private int internalPublic;

    public FeedModel() {
        super();
    }

    protected FeedModel(Parcel in) {
        feedId = in.readInt();
        uid = in.readInt();
        feedType = in.readInt();
        imgUrl = in.readString();
        videoUrl = in.readString();
        msg = in.readString();
        createTime = in.readLong();
        countLike = in.readInt();
        countComment = in.readInt();
        countRepost = in.readInt();
        city = in.readString();
        longitude = in.readInt();
        latitude = in.readInt();
        repostedFeed = in.readParcelable(RepostedFeedModel.class.getClassLoader());
        isLike = in.readByte() != 0;
        user = in.readParcelable(UserModel.class.getClassLoader());
        atUsers = in.createTypedArrayList(UserModel.CREATOR);
        labels = in.createStringArrayList();
        familyId = in.readInt();
        internalPublic = in.readInt();
    }

    public static final Creator<FeedModel> CREATOR = new Creator<FeedModel>() {
        @Override
        public FeedModel createFromParcel(Parcel in) {
            return new FeedModel(in);
        }

        @Override
        public FeedModel[] newArray(int size) {
            return new FeedModel[size];
        }
    };

    public int getFeedId() {
        return feedId;
    }

    public void setFeedId(int feedId) {
        this.feedId = feedId;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public int getFeedType() {
        return feedType;
    }

    public void setFeedType(int feedType) {
        this.feedType = feedType;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public int getCountLike() {
        return countLike;
    }

    public void setCountLike(int countLike) {
        this.countLike = countLike;
    }

    public int getCountComment() {
        return countComment;
    }

    public void setCountComment(int countComment) {
        this.countComment = countComment;
    }

    public int getCountRepost() {
        return countRepost;
    }

    public void setCountRepost(int countRepost) {
        this.countRepost = countRepost;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getLongitude() {
        return longitude;
    }

    public void setLongitude(int longitude) {
        this.longitude = longitude;
    }

    public int getLatitude() {
        return latitude;
    }

    public void setLatitude(int latitude) {
        this.latitude = latitude;
    }

    public FeedModel getRepostedFeed() {
        return repostedFeed;
    }

    public void setRepostedFeed(FeedModel repostedFeed) {
        this.repostedFeed = repostedFeed;
    }

    public boolean isLike() {
        return isLike;
    }

    public void setLike(boolean like) {
        isLike = like;
    }

    public UserModel getUser() {
        return user;
    }

    public void setUser(UserModel user) {
        this.user = user;
    }

    public List<UserModel> getAtUsers() {
        return atUsers;
    }

    public void setAtUsers(List<UserModel> atUsers) {
        this.atUsers = atUsers;
    }

    public boolean isIsLike() {
        return isLike;
    }

    public void setIsLike(boolean isLike) {
        this.isLike = isLike;
    }


    public List<String> getLabels() {
        return labels;
    }

    public void setLabels(List<String> labels) {
        this.labels = labels;
    }

    public int getFamilyId() {
        return familyId;
    }

    public void setFamilyId(int familyId) {
        this.familyId = familyId;
    }

    @Override
    public int getItemType() {
        if (feedType == 1) {
            return DynamicsParams.VIEWTYPE_LINEAR_IMAGE;
        } else if (feedType == 2) {
            return DynamicsParams.VIEWTYPE_LINEAR_VIDEO;
        }
        return DynamicsParams.VIEWTYPE_NONE;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(feedId);
        dest.writeInt(uid);
        dest.writeInt(feedType);
        dest.writeString(imgUrl);
        dest.writeString(videoUrl);
        dest.writeString(msg);
        dest.writeLong(createTime);
        dest.writeInt(countLike);
        dest.writeInt(countComment);
        dest.writeInt(countRepost);
        dest.writeString(city);
        dest.writeInt(longitude);
        dest.writeInt(latitude);
        dest.writeParcelable(repostedFeed, flags);
        dest.writeByte((byte) (isLike ? 1 : 0));
        dest.writeParcelable(user, flags);
        dest.writeTypedList(atUsers);
        dest.writeStringList(labels);
        dest.writeInt(familyId);
        dest.writeInt(internalPublic);
    }

    public int getInternalPublic() {
        return internalPublic;
    }

    public void setInternalPublic(int internalPublic) {
        this.internalPublic = internalPublic;
    }
}
